package com.ruoyi.project.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.GyWarping;
import com.ruoyi.project.service.IGyWarpingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工艺设计整经表Controller
 * 
 * @author xiangjun
 * @date 2021-12-14
 */
@RestController
@RequestMapping("/gongyi/gy_warping")
public class GyWarpingController extends BaseController
{
    @Autowired
    private IGyWarpingService gyWarpingService;

    /**
     * 查询工艺设计整经表列表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:list')")
    @GetMapping("/list")
    public TableDataInfo list(GyWarping gyWarping)
    {
        startPage();
        List<GyWarping> list = gyWarpingService.selectGyWarpingList(gyWarping);
        return getDataTable(list);
    }

    /**
     * 导出工艺设计整经表列表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:export')")
    @Log(title = "工艺设计整经表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GyWarping gyWarping)
    {
        List<GyWarping> list = gyWarpingService.selectGyWarpingList(gyWarping);
        ExcelUtil<GyWarping> util = new ExcelUtil<GyWarping>(GyWarping.class);
        return util.exportExcel(list, "工艺设计整经表数据");
    }

    /**
     * 获取工艺设计整经表详细信息
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gyWarpingService.selectGyWarpingById(id));
    }

    /**
     * 新增工艺设计整经表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:add')")
    @Log(title = "工艺设计整经表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GyWarping gyWarping)
    {
        return toAjax(gyWarpingService.insertGyWarping(gyWarping));
    }

    /**
     * 修改工艺设计整经表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:edit')")
    @Log(title = "工艺设计整经表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GyWarping gyWarping)
    {
        return toAjax(gyWarpingService.updateGyWarping(gyWarping));
    }

    /**
     * 删除工艺设计整经表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_warping:remove')")
    @Log(title = "工艺设计整经表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gyWarpingService.deleteGyWarpingByIds(ids));
    }
}
